﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using Enterprise.Service.Translation;
using System.IO;

namespace Enterprise.Service
{
    /// <summary>
    /// 页面基类
    /// </summary>
    public partial class BasePage:System.Web.UI.Page
    {

        /// <summary>
        /// 语种
        /// </summary>        
        public Language Language
        {
            get
            {
                if (Session["language"] == null)
                    Session["language"] = "zhcn";
                return (Language)Enum.Parse(typeof(Language),Session["language"].ToString());
            }
        }

        /// <summary>
        /// 翻译字符串
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string Tran(string str)
        {
            return Enterprise.Service.Translation.Translate.GetString(str);
        }

        /// <summary>
        /// 重写页面初始化
        /// </summary>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {                        
            base.OnInit(e);
        }

        /// <summary>
        /// 重写页面呈现，用于语言翻译
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreRenderComplete(EventArgs e)
        {
            base.OnPreRenderComplete(e);
            //当语言选项不是中文时 翻译成对应语言
            if (Language != Language.zhcn)
            {
                Translate.To(this.Page,this.Language);
            }                  
        }       
    }
}
